//
//  ColumnChartTitleView.m
//  MoneyLog
//
//  Created by wicresoft on 6/14/11.
//  Copyright 2011 wicresoft. All rights reserved.
//

#import "ColumnChartTitleView.h"


@implementation ColumnChartTitleView
@synthesize startDate,endDate;
@synthesize incomeValue,expenseValue,totalValue;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    CGContextRef context = UIGraphicsGetCurrentContext();
	//抗锯齿
	CGContextSetAllowsAntialiasing(context, TRUE);
    
	CGContextMoveToPoint(context, 0, 0);
	CGContextSaveGState(context);
    CGContextRestoreGState(context);
    
    float origionx = 30 ;
    float origiony = 10 ;
    
    [[UIColor redColor] setFill];
    CGContextFillRect(context, CGRectMake(origionx, origiony, 10, 10));
    CGContextDrawPath(context, kCGPathFill);
    
    [[UIColor blackColor] setFill];
    [@"支出" drawAtPoint:CGPointMake(origionx + 20, origiony-3) withFont:[UIFont systemFontOfSize:12]];
    [[NSString stringWithFormat:@"%.2f",expenseValue] drawAtPoint:CGPointMake(origionx + 60, origiony-3) withFont:[UIFont systemFontOfSize:12]];
    
    [[UIColor blueColor] setFill];
    CGContextFillRect(context, CGRectMake(origionx, origiony+20, 10, 10));
    CGContextDrawPath(context, kCGPathFill);
    
    [[UIColor blackColor] setFill];
    [@"收入" drawAtPoint:CGPointMake(origionx + 20, origiony+20-3) withFont:[UIFont systemFontOfSize:12]];
    [[NSString stringWithFormat:@"%.2f",incomeValue] drawAtPoint:CGPointMake(origionx + 60, origiony+20-3) withFont:[UIFont systemFontOfSize:12]];
    
    [[NSString stringWithFormat:@"合计：%.2f",totalValue] drawAtPoint:CGPointMake(origionx + 140, origiony+5) withFont:[UIFont systemFontOfSize:16]];
}


- (void)dealloc
{
    [super dealloc];
}

@end
